package com.example.rwq_test.designParttern.multiThread.readWriteLock;

/**
 * 读线程
 *
 * @author renweiqiang
 * @version 1.0.0
 * @createTime 2022/11/9
 */
public class ReaderThread extends Thread {
    private final Data data;

    public ReaderThread(Data data) {
        this.data = data;
    }

    public void run() {
        try {
            while (true) {
                char[] readBuf = data.read();
                System.out.println(Thread.currentThread().getName() + " reads " + String.valueOf(readBuf));
            }
        } catch (InterruptedException e) {
        }
    }
}
